import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Huevo here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Huevo extends Otros
{
    private int salud;
    private int pavos;
    /**
     * Act - do whatever the Huevo wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public Huevo()
    {
        salud=100;
        pavos=0;
    }
    public void act() 
    {
        Actor a;
        java.util.List c;
        c=getObjectsInRange(200, Cartman.class) ;
        World w=getWorld();
        Cartman ca=((Mundo)getWorld()).getCartman();
        if(!c.isEmpty()){
            if(pavos<5)
            {
                Greenfoot.delay(10);
                Pavo p=new Pavo(ca.getDir());
                w.addObject(p,getX(),getY());
                pavos++;
            }
            
        }
        
        if(isTouching(Bala.class)){
         a=getOneIntersectingObject(Bala.class);
         w.removeObject(a);
         salud-=((Bala)a).getDanio();
        }
        
        if(salud<=0){
         Caja b=new Caja();
         w.addObject(b,getX(),getY());
         w.removeObject(this);
         
        
        }
    }    
}
